import React from 'react';
import { inject, observer } from 'mobx-react';
import {
  WeaTop,
  WeaRightMenu,
  WeaErrorPage,
  WeaTools,
  WeaLocaleProvider,
} from 'ecCom';
import CenterContent from './center/CenterContent';
import { Synergy } from '../components/Portal/Portal';

const getLabel = WeaLocaleProvider.getLabel;
@inject('docCenterStore')

@observer
class Center extends React.Component {
  constructor(props){
    super(props);
    this.state={
      dropMenuProps:{
        collectParams: {
          favname: getLabel(132038, '知识中心'),
          favouritetype: 2,
          objid: 0,
          importantlevel: 1,
          link: 'wui/index.html#/main/document/center',
        },
      },
      collectParams:{
        favname: getLabel(132038, '知识中心'),
        favouritetype: 2,
        objid: 0,
        importantlevel: 1,
        link: 'wui/index.html#/main/document/center',
      }

    }
  }
  componentDidMount() {
    const { docCenterStore } = this.props;
    const { getNumOfAll, getNumOfMy, getNumOfReplyAndPraise
      , getRank, getLastestReader, getTabInfo, getDocList
      , getTabInfoOfPartner, getDocListOfPartner, getUserInfo
      , selectedKeyTabInfo, selectedKeyTabInfoOfPartner } = docCenterStore;
    getUserInfo();
    getTabInfo();
    getTabInfoOfPartner();
    getRank();
    getNumOfAll();
    getNumOfMy();
    getNumOfReplyAndPraise();
    getLastestReader();
    getDocList({ pageSize: 5, viewcondition: selectedKeyTabInfo });
    if (selectedKeyTabInfoOfPartner !== '3') {
 getDocListOfPartner(
        { pageSize: 100, viewcondition: selectedKeyTabInfoOfPartner });
}
  }
  componentWillReceiveProps() {
  }
  componentWillUnmount() {
  }
  onRightMenuClick() {
    const Arr = [];
    return Arr;
  }
  getRightMenu() {
    const Arr = [
    ];
    return Arr;
  }
  getButtons() {
    const Arr = [];
    return Arr;
  }
  render() {
    const { docCenterStore } = this.props;
    const { title, loading, loadingDocList, loadingDocListPartner } = docCenterStore;
    const loadingNow = loading || loadingDocList || loadingDocListPartner;
    return (
      <div className="wea-doc-center">
        <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@t9ae4b`}
          datas={this.getRightMenu()}
          onClick={this.onRightMenuClick}
          collectParams={this.state.collectParams}
        >
          <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@2e71wb`}
            title={title}
            loading={loadingNow}
            icon={<i className="icon-coms-doc" />}
            iconBgcolor="#df583a"
            buttons={this.getButtons()}
            buttonSpace={10}
            showDropIcon
            dropMenuDatas={this.getRightMenu()}
            dropMenuProps={this.state.dropMenuProps}
            onDropMenuClick={this.onRightMenuClick}
          >
            <CenterContent ecId={`${this && this.props && this.props.ecId || ''}_CenterContent@x83inq`} />
          </WeaTop>
        </WeaRightMenu>
        <Synergy ecId={`${this && this.props && this.props.ecId || ''}_Synergy@p1mufd`} pathname="/document/center" secid="-1" docid="-1" />
      </div>
    );
  }
}
export default WeaTools.tryCatch(React,
  props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@57ec8z`} msg={props.error ? props.error : getLabel(385218, '对不起，该页面异常，请联系管理员！')} />,
  { error: '' },
)(Center);

